<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>我的订单</title>
    <link rel="stylesheet" href="../../css/base.css">
    <link rel="stylesheet" href="../../css/personal/myorder.css">
    <link rel="stylesheet" href="../../css/tixian.css">
    <script src="../../js/jquery-2.2.3.min.js"></script>
    <script src="../../js/rem.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../detail/js/vue.min.js"></script>
    <script src="../detail/js/vue-resource.min.js"></script>
    <style>
        .cont-name2 p {
            display: inline-block !important;
            float: left;
        }

        .cont-logo img {
            width: 100%;
            float: left;
        }
        .f-s-btn{
            margin: 0 0.05rem;
        }
        .apply-goods{
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            position: fixed;
            z-index: 10000;
        }
        .applyContainer{
            height: 1.9rem;
            width: 3rem;
            background: #ffffff;
            margin: 0 auto;
            position: absolute;
            top: 50%;
            margin-top: -0.95rem;
            left: 50%;
            margin-left: -1.5rem;
            border-radius: 0.1rem;
        }
        .apply-number{
            height: 0.5rem;
            line-height: 0.5rem;
            color: #8E8E93;
            font-size: 0.14rem;
            text-align: right;
            padding: 0 0.2rem;
        }
        .apply-num{
            background-color: #ffffff;
            /* line-height: 0.5rem; */
            width: 0.5rem;
            color: #8E8E93;
            border: none;
            outline: none;
            /* border-bottom: 1px solid #000000; */
            text-align: right;
            margin: 0 0.05rem;
        }
        .canapply{
            width: 90%;
            margin: 0.2rem auto;
        }
        .apply-ul{
            width: 90%;
            margin: 0.1rem auto;
            position: relative;
            overflow: hidden;
        }
        .apply-ul li{
            text-align: center;
            width: 50%;
            float: left;
            height: 0.3rem;
            line-height: 0.3rem;
        }
        .apply-line{
            display:block; left: 50%;margin-left: -0.5px;background: #ccc; width:1px;
            top: 50%;
            margin-top: -0.1rem; height: 0.2rem; position:absolute;
        }
    </style>
</head>

<body style="background-color: #F5F5F5">
    <div class="apply-goods" style="display:none;">
        <div class="applyContainer">
            <p class="apply-number">请输入要提货数<input style="background: #ffffff;" class="apply-num" type="text">件</p>
            <div class="apply-num-con">

            </div>
            <ul class="apply-ul">
                <li class="apply-dis">取消</li>
                <span class="apply-line"></span>
                <li class="apply-shure" style="color: #EB4748;"></li>
            </ul>
        </div>
    </div>
    <div id="app">
        <div class="head" style="z-index:1002;">
            <div class="h-left" onclick="javascript:location.href='index.html'"></div>
            <div class="h-middle">我的订单</div>
            <div class="h-right"></div>
        </div>
        <div style="height: .44rem;"></div>
        <ul class="navBox" style="overflow-x:auto;">
            <li class="nav-item navActive">全部</li>
            <li class="nav-item nav-itemWait">已付款</li>
            <li class="nav-item nav-itemFukua">待付款</li>
            <li class="nav-item nav-itemFa">待收货</li>
            <li class="nav-item nav-itemRec">已完成</li>
        </ul>
        <div class="contBox">
            <!--全部-->
            <div class="cont-item cont-item-all">

            </div>
            <!-- 已付款 -->
            <div class="cont-item cont-item-wait">

            </div>
            <!--待付款-->
            <div class="cont-item cont-item-fukuan">

            </div>
            <!-- 代发货 -->
            <div class="cont-item cont-item-fa">

            </div>
            <!-- 待收货 -->
            <div class="cont-item cont-item-rec">

            </div>
        </div>
        <div class="tixian_password">
            <p class="title">输入支付密码</p>
            <img class="gb" src="../../img/g_tixian_gb.png" alt="" />
            <div class="input f_l">
                <input class="MM inpVal1" style="border-left:1px solid #909090;" type="password" class="" maxlength="1">
                <input class="MM inpVal2" type="password" maxlength="1">
                <input class="MM inpVal3" type="password" maxlength="1">
                <input class="MM inpVal4" type="password" maxlength="1">
                <input class="MM inpVal5" type="password" maxlength="1">
                <input class="MM inpVal6" type="password" maxlength="1">
            </div>
            <!--<a href="#" class="WJ_password">忘记密码?</a>-->
        </div>
    </div>

    <script>
        function GetRequest() {
            //获取url中"?"符后的字串 
            var url = location.search;
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                strs = str.split("&");
                for (var i = 0; i < strs.length; i++) {
                    theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        var theRequest = GetRequest();
        $(document).ready(function () {
            $(".navBox li").mouseover(function () {
                //通过 .index()方法获取元素下标，从0开始，赋值给某个变量
                var _index = $(this).index();
                //让内容框的第 _index 个显示出来，其他的被隐藏
                $(".contBox>div").eq(_index).show().siblings().hide();
                //改变选中时候的选项框的样式，移除其他几个选项的样式
                $(this).addClass("navActive").siblings().removeClass("navActive");
            });
        });
        // console.log()
        let data = {
            userId: localStorage.getItem('userId'),
            pageNum: 1
        }
        $.ajax({
            url: SURL + '/jfd/shopOrders/getAllOrderData',
            data: data,
            // dataType: 'json',
            type: 'POST',
            success: res => {
                // 全部订单
                var order = res.data.data
                var orders1 = order.filter(ele => ele.orderType == 3)
                //orders数组
                orders1.forEach(currentAll => {
                    currentAll.shopOrdersList.forEach(element => {
                        var allDiv =
                            `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2"></div>
                                    </div>
                                `
                        element.orderGoodsList.forEach(eleCur => {
                            allDiv +=
                                `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                        })
                        allDiv +=
                            `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                        $('.cont-item-all').append(allDiv)
                    });
                });
                //待付款
                $('.nav-itemFukua').click(() => {
                    $('.cont-item-fukuan').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            -2)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待付款</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                           <div class="cont-submit redBtn" data-un="${element.orderunique}" onclick="subPay(this)" >去支付</div>
                            <div class="cont-submit qxBtn" onclick="deleteOrder(this)" data-id="${element.orderId}">取消订单</div>
                        </div>
                        `
                            $('.cont-item-fukuan').append(allDiv)
                        });
                    });
                });
                // 已付款订单
                $('.nav-itemWait').click(() => {
                    $('.cont-item-wait').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            0)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已付款</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                            $('.cont-item-wait').append(allDiv)
                        });
                    });
                });
                // 待收货
                $('.nav-itemFa').click(() => {
                    $('.cont-item-fa').text('');
                    console.log(orders1)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            1)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待收货</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                            $('.cont-item-fa').append(allDiv)
                        });
                    });
                })

                //已完成
                $('.nav-itemRec').click(() => {
                    $('.cont-item-rec').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            5)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已完成</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                                <div class="c-i-bottom">
                                    共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                                </div>
                            </div>
                        `
                            $('.cont-item-rec').append(allDiv)
                        });
                    });
                })
            }
        })
        if (theRequest.ling == 1) { //待发货
            $('.nav-itemWait').addClass('navActive')
            $('.nav-itemWait').siblings().removeClass('navActive')
            $('.cont-item-wait').show();
            $('.cont-item-wait').siblings().hide();
            $.ajax({
                url: SURL + '/jfd/shopOrders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType == 3)
                    $('.cont-item-wait').text('');
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            0)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">已付款</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                            $('.cont-item-wait').append(allDiv)
                        });
                    });
                }
            })

        } else if (theRequest.ling == 2) { //待收货
            $('.nav-itemFa').addClass('navActive')
            $('.nav-itemFa').siblings().removeClass('navActive')
            $('.cont-item-fa').show();
            $('.cont-item-fa').siblings().hide();
            $('.cont-item-fa').html('');
            $.ajax({
                url: SURL + '/jfd/shopOrders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType != 3)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            1)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待收货</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsName}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                            <div class="c-i-bottom">
                                共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                            </div>
                        </div>
                        `
                            $('.cont-item-fa').append(allDiv)
                        });
                    });
                }
            })

        } else if (theRequest.ling == 3) { //已完成
            $('.nav-itemRec').addClass('navActive')
            $('.nav-itemRec').siblings().removeClass('navActive')
            $('.cont-item-rec').show();
            $('.cont-item-rec').siblings().hide();
            // $('.cont-item-rec').text('');
            $.ajax({
                url: SURL + '/jfd/shopOrders/getAllOrderData',
                data: data,
                // dataType: 'json',
                type: 'POST',
                success: res => {
                    var order = res.data.data
                    var orders1 = order.filter(ele => ele.orderType != 3)
                    orders1.forEach(currentAll => {
                        var ordersf = currentAll.shopOrdersList.filter(shopf => shopf.orderStatus ==
                            5)
                        ordersf.forEach(element => {
                            var allDiv =
                                `
                                <div class="cont">
                                    <div class="c-i-top">
                                        ${currentAll.logo?'<img src="${currentAll.logo}" class="dpimg" alt="">':'<img src="../../img/g_tx.png" class="dpimg" alt="">'}
                                        <div class="top-box"></div>
                                        <div class="top-box2">待发货</div>
                                    </div>
                                `
                            element.orderGoodsList.forEach(eleCur => {
                                allDiv +=
                                    `
                                <div class="c-i-middle" data-id="${eleCur.orderId}" onclick="orderDetail(this)">
                                    <img src="${eleCur.goodsImg}" class="i-yanjing" alt="">
                                    <div class="middle-name">${eleCur.goodsPrice}</div>
                                    <div class="middle-money">￥${eleCur.goodsPrice}</div>
                                    <div class="middle-money2"> <u>￥${eleCur.goodsPrice}</u> </div>
                                    <div class="middle-num">×${eleCur.goodsNum}</div>
                                </div>
                                `
                            })
                            allDiv +=
                                `
                                <div class="c-i-bottom">
                                    共1件商品 合计：￥<span class="bottom-money">${element.totalMoney}</span>
                                </div>
                            </div>
                        `
                            $('.cont-item-rec').append(allDiv)
                        });
                    });
                }
            })

        }
        // 取消订单
        function deleteOrder(e) {
            var orderId = $(e).attr('data-id');
            $.ajax({
                url: SURL + '/jfd/ordersGoods/updateOrderStatus',
                data: {
                    orderId: orderId,
                    orderStatus: -1
                },
                type: 'get',
                dataType: 'json',
                success: res => {
                    // res.code==1?
                    // console.log(res);
                    if (res.code == 1) {
                        alert(res.msg);
                        window.location.reload();
                    }
                }
            })
        }
        // 查看详情点击
        function lookDetail(e) {
            var orderId = $(e).attr('data-id');
            window.location.href = "order-dfk.html?orderId=" + orderId;
        }

        function orderDetail(e) {
            var orderId = $(e).attr('data-id');
            window.location.href = "order-dfk.html?orderId=" + orderId;
        }

        var app = new Vue({
            el: '#app',
            mounted() {
                // this.$http.post(SURL + '/jfd/ordersGoods/getAllOrderData',{userId:localStorage.getItem('userId'),orderStatus:0},{emulateJSON : true}).then(function (res) {
                //     console.log(res);
                // })
            }
        })
        // 支付
        $(function () {
            $('.tixian_password .gb').click(function () {
                $('.overlay').hide();
                $('.contBox').show();
                $('.tixian_password').hide();
            })
        })

        function subPay(e) {
            $('.cont-item-pay').attr('data-index', '');
            var uniqueCon = $(e).attr('data-un');
            $('.overlay').show();
            $('.contBox').hide();
            $('.tixian_password').show();
            $('.tixian_password').attr('data-un', uniqueCon)
            var contIndex = $(e).parent('.cont').index();
            $('.tixian_password').attr('data-index', contIndex)
        }
        // 申请提货
        function pickGoods(e) {
            $('.apply-shure').text('提货')
            $('.apply-num-con').html('');
            $('.apply-goods').show();
            $('.apply-shure').unbind('click');
            // alert(Math.ceil(23*0.4));
            var dataId = $(e).attr('data-id');
            // $('.apply-shure').click(()=>{
            $.ajax({
                url: SURL + '/jfd/shopOrders/toApplyGoods',
                data: {
                    type: 1,
                    orderId: dataId
                },
                type: 'post',
                dataType: 'json',
                success: res => {
                    console.log(res);
                    $('.apply-num-con').append(
                        `
                        <p style="width: 90%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        <p class="canapply">您当前商品总件数为${res.data[0].goodsNum}件，可提货件数不得大于${res.data[0].maxSendNum}件也不能小于${res.data[0].minSendNum}件。</p>
                        <p style="width: 100%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        `
                    )
                    $('.apply-shure').unbind('click').on("click", () => {
                        var applyNum = parseInt($('.apply-num').val());
                        console.log(applyNum)
                        if (applyNum > res.data[0].maxSendNum) {
                            alert('最大不能超过' + res.data[0].maxSendNum + '件')
                        } else if (applyNum < res.data[0].minSendNum) {
                            alert('最少不能少于' + res.data[0].minSendNum + '件');
                        } else {
                            var arr = [];
                            var ordersGoods = res.data[0].ordersGoodsId;
                            paramStrObj = {
                                ordersGoodsId: ordersGoods,
                                applyNum: applyNum
                            }
                            arr.push(paramStrObj);
                            var arr1 = JSON.stringify(arr)
                            var data = {
                                type: 1,
                                paramStr: arr1,
                                userId: localStorage.getItem('userId')
                            }
                            console.log(data)
                            $.ajax({
                                url: SURL + '/jfd/shopOrders/applyGoods',
                                data: data,
                                type: 'post',
                                dataType: 'json',
                                traditional: true,
                                success: res => {
                                    console.log(res);
                                    alert(res.msg)
                                    $('.apply-goods').hide();
                                }
                            })
                        }
                    })
                }
                // })
            })
        }
        // 申请库存
        function Inventory(e) {
            $('.apply-num-con').html('');
            $('.apply-shure').text('放入库存')
            $('.apply-goods').show();
            // alert(Math.ceil(23*0.4));
            var dataId = $(e).attr('data-id');
            // $('.apply-shure').click(()=>{
            $.ajax({
                url: SURL + '/jfd/shopOrders/toApplyGoods',
                data: {
                    type: 2,
                    orderId: dataId
                },
                type: 'post',
                dataType: 'json',
                success: res => {
                    console.log(res);
                    $('.apply-num-con').append(
                        `
                        <p style="width: 90%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        <p class="canapply">您当前商品总件数为${res.data[0].goodsNum}件，可放入库存件数不得大于${res.data[0].maxStockNum}件也不能小于${res.data[0].minStockNum}件。</p>
                        <p style="width: 100%;margin: 0.1rem auto 0.1rem auto;height:1px;background:#E3E3E3;"></p>
                        `
                    )
                    $('.apply-shure').unbind('click').on("click", () => {
                        var applyNum = $('.apply-num').val();
                        if (applyNum > res.data[0].maxStockNum) {
                            alert('最大不能超过' + res.data[0].maxStockNum + '件')
                        } else if (applyNum < res.data[0].minStockNum) {
                            alert('最少不能少于' + res.data[0].minStockNum + '件')
                        } else {
                            var arr = [];
                            var ordersGoods = res.data[0].ordersGoodsId;
                            paramStrObj = {
                                ordersGoodsId: ordersGoods,
                                applyNum: applyNum
                            }
                            arr.push(paramStrObj);
                            var arr1 = JSON.stringify(arr)
                            var data = {
                                type: 2,
                                paramStr: arr1,
                                userId: localStorage.getItem('userId')
                            }
                            console.log(applyNum)
                            $.ajax({
                                url: SURL + '/jfd/shopOrders/applyGoods',
                                data: data,
                                type: 'post',
                                dataType: 'json',
                                traditional: true,
                                success: res => {
                                    console.log(res)
                                    alert(res.msg)
                                    $('.apply-goods').hide();
                                }
                            })
                        }
                    })
                }
                // })
            })
        }
        $('.apply-dis').click(() => {
            $('.apply-goods').hide();
        })
    </script>
    <script>
        (function (window, document) {
            var active = 0,
                inputBtn = document.getElementsByClassName('MM');
            for (var i = 0; i < inputBtn.length; i++) {
                inputBtn[i].addEventListener('click', function () {
                    inputBtn[active].focus();
                }, false);
                inputBtn[i].addEventListener('focus', function () {
                    this.addEventListener('keyup', listenKeyUp, false);
                }, false);
                inputBtn[i].addEventListener('blur', function () {
                    this.removeEventListener('keyup', listenKeyUp, false);
                }, false);
            }

            /*监听键盘的敲击事件*/
            function listenKeyUp() {
                if (!isNaN(this.value) && this.value.length != 0) {
                    if (active < 5) {
                        // console.log(active);
                        active += 1;
                    } else if (active == 5) {
                        // console.log(333);

                        var int = document.getElementsByClassName('MM ')
                        var srt = ''
                        for (i = 0; i < int.length; i++) {
                            srt += int[i].value
                        }
                        var dataIndex = $('.cont-item-pay').attr('data-index');
                        var orderRemarks = $('.tixian_password').children('.cont-item-pay').eq(dataIndex).text();
                        var orderun = $('.tixian_password').attr('data-un');
                        console.log(orderun)
                        $.ajax({
                            url: SURL + '/jfd/shopOrders/payOrders',
                            data: {
                                orderunique: orderun,
                                userId: localStorage.getItem('userId'),
                                paypassword: srt,
                                orderRemarks: ''
                            },
                            type: 'post',
                            dataType: 'json',
                            success: res => {
                                // console.log(res)
                                alert(res.msg);
                                if (res.code == 0) {
                                    window.location.reload()
                                }
                            }
                        })
                    }
                    inputBtn[active].focus();
                } else if (this.value.length == 0) {
                    // console.log(2222);
                    if (active > 0) {
                        active -= 1;
                    }
                    inputBtn[active].focus();
                }
            }


        })(window, document);
    </script>
</body>

</html>
